home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 765 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: elesueur@ens-lyon.fr (Emmanuel Lesueur)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Static member functions and overloading resolution
  5. Date: 18 Mar 1996 20:34:56 GMT
  6. Organization: Ecole Normale Superieure de Lyon, France
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Distribution: world
  9. Message-ID: <4ikb60$4i@cri.ens-lyon.fr>
  10. References: <4ifv63$qsk@engnews1.Eng.Sun.COM>
  11. Reply-To: elesueur@ens-lyon.fr
  12. NNTP-Posting-Host: taumet.eng.sun.com
  13. X-Nntp-Posting-Host: neron.ens-lyon.fr
  14. Content-Length: 932
  15. X-Lines: 33
  16. Originator: clamage@taumet
  17.  
  18. In article <4ifv63$qsk@engnews1.Eng.Sun.COM>, clamage@Eng.Sun.COM (Steve Clamage) writes:
  19. >According to the way you wrote your example, the first
  20. >candidate is the non-static f(int). It requires a conversion
  21. >from B& to A& on the first argument, and a promotion of char
  22. >to int on the second. The second candidate, static f(char), has
  23. >an exact match on any first argument (since it is a fiction anyway),
  24. >and an exact match (char to char) on the second argument.
  25. >There is no ambiguity, and the static f(char) should be selected.
  26.  
  27. Oops... You're right, of course. I swapped the function parameters.
  28. What about:
  29.  
  30. >    class A {
  31. >    public:
  32. >        void f(char);
  33. >        static void f(int);
  34. >    };
  35.  
  36. >    class B : public A {
  37. >    };
  38.  
  39. >    void foo(B& b,char c) {
  40. >        b.f(c);
  41. >    }
  42.  
  43. Is this ambiguous ? As I understand it, the draft paper says yes.
  44. (gcc says no.)
  45.  
  46. ___________________________________________________
  47.  
  48. Emmanuel Lesueur  -   elesueur@ens-lyon.fr
  49.  
  50.  
  51.  
  52.  
  53. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your
  54.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  55.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  56.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  57.   Comments? mailto:std-c++-request@ncar.ucar.edu
  58. ]
  59.